<template>
    <div>
       <table>
        <tr>
            <td>名称</td>
            <td><input type="text" v-model="state.pname"></td>
        </tr>
        <tr>
            <td>数量</td>
            <td><input type="text" v-model="state.pnum"></td>
        </tr>
        <tr>
            <td>单价</td>
            <td>
                <input type="text" v-model="state.pprice">         
            </td>
        </tr>
        <tr>
            <td>类型</td>
            <td><input type="text" v-model="state.pxiala"></td>
        </tr>
   
        <tr>
            <td>
             <input type="button" value="添加" @click="tianjia">
            </td>
            <td></td>
        </tr>
       </table>
    </div>
</template>

<script setup lang="ts">
import {reactive, toRefs, onMounted } from 'vue';
import {useRoute,useRouter} from 'vue-router'
import axios from 'axios'
const route = useRoute()
const router = useRouter()

const data = reactive({
   state:{
    pname:'',
    pnum:'',
    pprice:'',
    pxiala:'',
   
   
   }

})

const {state} = toRefs(data)


 
const tianjia = ()=>{
    if(state.value.pname == ''){
        alert('姓名不能为空')
        return
    }
    if(state.value.pnum == ''){
        alert('手机号不能为空')
        return
    }
    if(state.value.pprice == ''){
        alert('图片不能为空')
        return
    }
    if(state.value.pxiala == ''){
        alert('时间不能为空')
        return
    }
   
    axios({
         url:'https://localhost:7239/api/Member/AddProper',
         method:'post',
         data:state.value
    }).then((res)=>{
   
        if(res.data.data >0){
            alert('添加成功')
            
        }else{
            alert('添加失败')
        }
    })
}

</script>

<style scoped>

</style>